const { ImagesModel } = require('../../models/index');

// 获取首页轮播图
const getIndexCarousel = async (req, res) => {
  try {
    const carousels = await ImagesModel.findAll({
      attributes: ['images_id', 'url'],
      where: {
        decorate: 'carousel-index'
      }
    })
    res.status(200).json({
      title: '首页轮播图',
      data: carousels
    })
  } catch (error) {
    res.status(500).json({
      error: error.message
    })
  }
}

module.exports = {
  getIndexCarousel,
}